package com.sohu.pickoo.frag;

import java.util.Calendar;
import java.util.Date;

import org.quartz.CronTrigger;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;

import com.sohu.peak.util.Logger;


public class NewFragServer {

	public void run() throws Exception {
        Logger log = new Logger();

        log.debug("------- 设置获取新碎片定时器-------------------");

        // First we must get a reference to a scheduler
        SchedulerFactory sf = new StdSchedulerFactory();
        Scheduler sched = sf.getScheduler();
        
        JobDetail job = new JobDetail("getFragjob", "group3", GetFragJob.class);
        JobDataMap dataMap = new JobDataMap();
        Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.YEAR,1900);
		Date mTime = calendar.getTime();
        dataMap.put("mTime",mTime);
        job.setJobDataMap(dataMap);
        CronTrigger trigger = new CronTrigger("gettrigger", "group3", "getFragjob",
                        "group3", "1 */1 * * * ?");
        sched.addJob(job, true);
        Date ft = sched.scheduleJob(trigger);
        log.debug(job.getFullName() + " has been scheduled to run at: " + ft
                        + " and repeat based on expression: ");

        sched.start();

        log.debug("------- Started Scheduler -----------------");
    }

    public static void main(String[] args) throws Exception {
    	NewFragServer server = new NewFragServer();
    	server.run();
    }
}
